<?php

namespace IDock\Insurance\DAJIA\Response;

use IDock\Http\Response;
use IDock\Insurance\DAJIA\Response\AllDAJIAResponse;
use IDock\Printer\PolicyPaymentPrinter;

class PolicyPaymentResponse extends AllDAJIAResponse
{

    public function printerInit(): Response
    {
        $policyPaymentPrinter = new PolicyPaymentPrinter();

        $data = $this->get('body',[]);
        $url = $data['result']['signInfoUrl'] ?? '';
        if(empty($url)){
            $this->setError("获取电子签名链接失败：".$data['message']);
            $this->printer = $policyPaymentPrinter;
            return $this;
        }
        $policyPaymentPrinter->payUrl = $url;

        $this->printer = $policyPaymentPrinter;
        return $this;
    }
}